package tech.aistar.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import tech.aistar.entity.House;
import tech.aistar.service.IHouseService;

import javax.servlet.http.HttpServletRequest;
import java.util.List;

@Controller
@RequestMapping("/home")
public class HomeController {

    @Autowired
    private IHouseService houseService;

    //首页初始页面
    @RequestMapping("/page")
    public String Home(HttpServletRequest request) {
        List<House> houseList = houseService.selectHouseLimit();
        request.setAttribute("house", houseList);
        return "/home_page/home";
    }

    //安全退出
    @RequestMapping("/exit")
    public String Exit(HttpServletRequest request) {
        //清空session中所有数据
        request.getSession().invalidate();

        //重定向到登录页面
        return "redirect:/login/check";
    }

    //重定向首页
    @RequestMapping("/home")
    public String toHome() {
        return "redirect:/home/page";
    }

    //跳整租
    @RequestMapping("/WholeRent")
    public String WholeRent() {
        return "redirect:/House/Zheng";
    }

    //跳合租
    @RequestMapping("/togetherRent")
    public String togetherRent() {
        return "redirect:/House/Hezu";
    }

}